# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -O0 -mtriple aarch64 -run-pass=legalizer -verify-machineinstrs %s -o - | FileCheck %s

name:            test_constant
registers:
body: |
  bb.0:
    liveins: $x0
    ; CHECK-LABEL: name: test_constant
    ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
    ; CHECK: $w0 = COPY [[C]](s32)
    ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 42
    ; CHECK: $w0 = COPY [[C1]](s32)
    ; CHECK: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 -1
    ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY [[C2]](s32)
    ; CHECK: $w0 = COPY [[COPY]](s32)
    ; CHECK: $w0 = COPY [[C2]](s32)
    ; CHECK: [[C3:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
    ; CHECK: $x0 = COPY [[C3]](s64)
    ; CHECK: [[C4:%[0-9]+]]:_(s64) = G_CONSTANT i64 0
    ; CHECK: $x0 = COPY [[C4]](s64)
    %0:_(s1) = G_CONSTANT i1 0
    %6:_(s32) = G_ANYEXT %0
    $w0 = COPY %6
    %1:_(s8) = G_CONSTANT i8 42
    %7:_(s32) = G_ANYEXT %1
    $w0 = COPY %7
    %2:_(s16) = G_CONSTANT i16 65535
    %8:_(s32) = G_ANYEXT %2
    $w0 = COPY %8
    %3:_(s32) = G_CONSTANT i32 -1
    $w0 = COPY %3
    %4:_(s64) = G_CONSTANT i64 1
    $x0 = COPY %4
    %5:_(s64) = G_CONSTANT i64 0
    $x0 = COPY %5
...

---
name:            test_fconstant
body: |
  bb.0:
    liveins: $x0
    ; CHECK-LABEL: name: test_fconstant
    ; CHECK: [[C:%[0-9]+]]:_(s32) = G_FCONSTANT float 1.000000e+00
    ; CHECK: $w0 = COPY [[C]](s32)
    ; CHECK: [[C1:%[0-9]+]]:_(s64) = G_FCONSTANT double 2.000000e+00
    ; CHECK: $x0 = COPY [[C1]](s64)
    ; CHECK: [[C2:%[0-9]+]]:_(s32) = G_FCONSTANT float 0.000000e+00
    ; CHECK: [[FPTRUNC:%[0-9]+]]:_(s16) = G_FPTRUNC [[C2]](s32)
    ; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[FPTRUNC]](s16)
    ; CHECK: $w0 = COPY [[ANYEXT]](s32)
    %0:_(s32) = G_FCONSTANT float 1.0
    $w0 = COPY %0
    %1:_(s64) = G_FCONSTANT double 2.0
    $x0 = COPY %1
    %2:_(s16) = G_FCONSTANT half 0.0
    %3:_(s32) = G_ANYEXT %2
    $w0 = COPY %3
...

---
name:           s792
registers:
body: |
  bb.0:
    liveins: $x0
    ; CHECK-LABEL: name: s792
    ; CHECK: %trunc:_(s32) = G_CONSTANT i32 0
    ; CHECK: $w0 = COPY %trunc(s32)
    ; CHECK: RET_ReallyLR implicit $w0
    %cst:_(s792) = G_CONSTANT i792 0
    %trunc:_(s32) = G_TRUNC %cst(s792)
    $w0 = COPY %trunc(s32)
    RET_ReallyLR implicit $w0
...
